#!/home/xuguoqun/anaconda3/bin/python
# -*- coding: utf-8 -*-
# @CreateTime    : 2020/5/18 19:40
# @Author  : xuguoqun
# @Email   : gqxu@a-y.com.cn
# @File    : Url_Factory.py
# @Company: Nanjing-Anyuan
from yunying.Time import Time
from urllib import parse


class Url_Factory(object):
    def __init__(self):
        self.base_url = 'https://www.sinochemlogistics.com/napi/enterprise/getActiveUserList'
        self.switch_url = 'https://www.sinochemlogistics.com/my/switchEnt?enterprise_id='
        self.page = 1
        self.perPage = 100

    ##拼接主要请求URL
    def url_splice(self,page=1,perPage=100):
        self.page = page
        self.perPage = perPage
        time = Time().available()
        starttime = time[0]
        endtime = time[1]
        s1 = parse.quote(starttime)
        s2 = parse.quote(endtime)
        self.link_url = self.base_url + '?page=' + str(self.page) + '&perPage=' + str(
            self.perPage) + '&from=' + s1 + '&to=' + s2
        return self.link_url

    ##拼接切换企业容器的URL
    def switch_enterprise(self,enterpriselist):
        new_enterpriselist=[]
        for ent in enterpriselist:
            new_enterpriselist.append(self.switch_url+ent)
        return new_enterpriselist

    ##拼接指定企业容器的URL
    def switch_rongqi(self,rongqi):
        url = self.switch_url+rongqi
        return url

